
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>数据结构 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="数据结构高级内容.html" />
    
    
    <link rel="prev" href="字符串处理.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="基础.html">
            
                <a href="基础.html">
            
                    
                    基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="字符串处理.html">
            
                <a href="字符串处理.html">
            
                    
                    字符串处理
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4" data-path="数据结构.html">
            
                <a href="数据结构.html">
            
                    
                    数据结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="数据结构高级内容.html">
            
                <a href="数据结构高级内容.html">
            
                    
                    数据结构高级内容
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="函数.html">
            
                <a href="函数.html">
            
                    
                    函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="函数式编程.html">
            
                <a href="函数式编程.html">
            
                    
                    函数式编程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="面向对象编程.html">
            
                <a href="面向对象编程.html">
            
                    
                    面向对象编程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="类的特殊方法.html">
            
                <a href="类的特殊方法.html">
            
                    
                    类的特殊方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="异常处理.html">
            
                <a href="异常处理.html">
            
                    
                    异常处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="IO编程.html">
            
                <a href="IO编程.html">
            
                    
                    IO编程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="模块.html">
            
                <a href="模块.html">
            
                    
                    模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="标准库.html">
            
                <a href="标准库.html">
            
                    
                    标准库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="测试.html">
            
                <a href="测试.html">
            
                    
                    测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="调试.html">
            
                <a href="调试.html">
            
                    
                    调试
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >数据结构</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x6570;&#x636E;&#x7ED3;&#x6784;">&#x6570;&#x636E;&#x7ED3;&#x6784;</h1>
<hr>
<h2 id="&#x5B57;&#x7B26;&#x4E32;&#xFF08;str&#xFF09;">&#x5B57;&#x7B26;&#x4E32;&#xFF08;str&#xFF09;</h2>
<ol>
<li>&#x5B57;&#x7B26;&#x4E32;&#x662F;&#x4E0D;&#x53EF;&#x53D8;&#x7684;</li>
<li>&#x5B57;&#x7B26;&#x4E32;&#x8FDE;&#x63A5;<pre><code class="lang-python"><span class="hljs-string">&apos;a&apos;</span> + <span class="hljs-string">&apos;b&apos;</span>  <span class="hljs-comment">#&#x7B49;&#x4EF7;&#x4E8E;&#xFF1A;&apos;ab&apos;</span>
<span class="hljs-string">&apos;hello &apos;</span> + <span class="hljs-string">&apos;world &apos;</span> + str(<span class="hljs-number">100</span>)   <span class="hljs-comment">#&#x7B49;&#x4EF7;&#x4E8E;&#xFF1A;&apos;hello world {}&apos;.format(100)</span>
</code></pre>
<blockquote>
<p>&#x6CE8;&#xFF1A;&#x6BD4;&#x8F83;&#x96BE;&#x770B;&#xFF0C;&#x4E14;&#x5BB9;&#x6613;&#x51FA;&#x9519;</p>
</blockquote>
</li>
<li>&#x5B57;&#x7B26;&#x4E32;&#x91CD;&#x590D;<pre><code class="lang-python">&#x2018;a&#x2019; * <span class="hljs-number">3</span>     <span class="hljs-comment">#&#x7B49;&#x4EF7;&#x4E8E;&#xFF1A;&apos;aaa&apos;</span>
</code></pre>
</li>
<li>&#x5B57;&#x7B26;&#x4E32;&#x6BD4;&#x8F83;<pre><code class="lang-python"><span class="hljs-string">&apos;str&apos;</span> == <span class="hljs-string">&apos;stri&apos;</span>  <span class="hljs-comment">#&#x7ED3;&#x679C;&#x4E3A;False</span>
<span class="hljs-string">&apos;str&apos;</span> != <span class="hljs-string">&apos;stri&apos;</span>  <span class="hljs-comment">#&#x7ED3;&#x679C;&#x4E3A;True</span>
</code></pre>
</li>
<li>&#x5229;&#x7528;&#x5207;&#x7247;&#x5F97;&#x5230;&#x5B57;&#x7B26;&#x4E32;&#x9006;&#x5E8F;&#x7684;&#x62F7;&#x8D1D;<pre><code class="lang-python">s1 = <span class="hljs-string">&apos;hello&apos;</span>
s2 = s1[::<span class="hljs-number">-1</span>]   <span class="hljs-comment"># &apos;olleh&apos;</span>
</code></pre>
</li>
<li>&#x76F8;&#x90BB;&#x7684;&#x4E24;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x5E38;&#x91CF;(&#x4E0D;&#x53EF;&#x4EE5;&#x662F;&#x53D8;&#x91CF;&#x6216;&#x8868;&#x8FBE;&#x5F0F;)&#x4F1A;&#x81EA;&#x52A8;&#x8FDE;&#x63A5;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;<pre><code class="lang-python"><span class="hljs-string">&apos;py&apos;</span><span class="hljs-string">&apos;thon&apos;</span>  <span class="hljs-comment">#&#x7B49;&#x4EF7;&#x4E8E;&apos;python&apos;</span>
text = (<span class="hljs-string">&apos;erick &apos;</span>
     <span class="hljs-string">&apos;huang&apos;</span>)    <span class="hljs-comment">#&#x7B49;&#x4EF7;&#x4E8E;text = &apos;erick huang&apos;</span>
</code></pre>
</li>
</ol>
<h2 id="&#x5143;&#x7EC4;&#xFF08;tuple&#xFF09;">&#x5143;&#x7EC4;&#xFF08;tuple&#xFF09;</h2>
<blockquote>
<p>&#x5143;&#x7EC4;&#x7684;&#x5706;&#x62EC;&#x53F7;&#x5176;&#x5B9E;&#x662F;&#x53EF;&#x9009;&#x7684;&#xFF0C;&#x9664;&#x4E86;&#x4EE5;&#x4E0B;&#x4E24;&#x79CD;&#x60C5;&#x51B5;&#x5916;&#xFF1A;<br>1&#xFF09;&#x8868;&#x793A;&#x4E00;&#x4E2A;&#x7A7A;&#x5143;&#x7EC4;&#xFF1B;<br>2&#xFF09;&#x8BED;&#x6CD5;&#x4E0A;&#x6709;&#x4E8C;&#x4E49;&#x6027;&#x7684;&#x573A;&#x5408;&#x3002;&#x4F8B;&#x5982;&#x51FD;&#x6570;&#x8C03;&#x7528;&#x4E2D;f((a, b, c))&#x4E2D;&#x662F;&#x4E00;&#x4E2A;&#x5143;&#x7EC4;&#x5B9E;&#x53C2;&#xFF0C;&#x800C;f(a,b,c)&#x662F;&#x4E09;&#x4E2A;&#x53C2;&#x6570;&#x3002; </p>
</blockquote>
<p><strong>&#x7279;&#x70B9;</strong><br>&#x6709;&#x5E8F;&#x3001;&#x4E0D;&#x53EF;&#x53D8;&#xFF08;&#x4E0D;&#x53EF;&#x589E;&#x5220;&#x5143;&#x7D20;&#xFF0C;&#x4F46;&#x53EF;&#x4EE5;&#x5305;&#x542B;&#x53EF;&#x53D8;&#x7C7B;&#x578B;&#x7684;&#x5143;&#x7D20;&#xFF09;  </p>
<p><strong>&#x521B;&#x5EFA;</strong>  </p>
<pre><code>()  &#x6216;  tuple()    #&#x7A7A;&#x5143;&#x7EC4;
a,  &#x6216;  (a,)       #&#x5355;&#x5143;&#x7D20;&#x7684;&#x5143;&#x7EC4;
a,b,c &#x6216; (a,b,c)   #&#x591A;&#x5143;&#x7D20;&#x7684;&#x5143;&#x7EC4;
tuple(iterable)    #&#x6CE8;&#x610F;&#xFF0C;&#x5982;&#x679C;iterable&#x662F;&#x4E00;&#x4E2A;tuple&#xFF0C;&#x5219;&#x76F4;&#x63A5;&#x8FD4;&#x56DE;&#x5F15;&#x7528;&#xFF0C;&#x4E0D;&#x4F1A;&#x62F7;&#x8D1D;&#x4E00;&#x4E2A;&#x526F;&#x672C;
&#x4E3E;&#x4F8B;&#xFF1A;
t = 1,2,3   #&#x7B49;&#x4EF7;&#x4E8E;&#xFF1A;t = (1,2,3)
</code></pre><p><strong>&#x904D;&#x5386;</strong>  </p>
<pre><code class="lang-python"><span class="hljs-keyword">for</span> x <span class="hljs-keyword">in</span> mytuple:  
    print(x)
<span class="hljs-keyword">for</span> i,x <span class="hljs-keyword">in</span> enumerate(mytuple):  
    print(i, x)
</code></pre>
<h2 id="&#x5217;&#x8868;&#xFF08;list&#xFF09;">&#x5217;&#x8868;&#xFF08;list&#xFF09;</h2>
<p><strong>&#x7279;&#x70B9;</strong><br>&#x6709;&#x5E8F;&#x3001;&#x53EF;&#x53D8;&#xFF08;&#x53EF;&#x589E;&#x5220;&#x5143;&#x7D20;&#xFF09;  </p>
<p><strong>&#x521B;&#x5EFA;</strong>  </p>
<pre><code>[]  &#x6216;  list()   #&#x7A7A;&#x5217;&#x8868;
[1,2,3]          #&#x5355;&#x5143;&#x7D20;&#x6216;&#x591A;&#x5143;&#x7D20;
[x for in iterable]  #&#x5217;&#x8868;&#x8868;&#x8FBE;&#x5F0F;
list(iterable)   #&#x5982;&#x679C;iterable&#x662F;&#x4E00;&#x4E2A;list,&#x5219;&#x4F1A;&#x62F7;&#x8D1D;&#x4E00;&#x4E2A;&#x526F;&#x672C;&#xFF0C;&#x5B83;&#x7B49;&#x4EF7;&#x4E8E;iterable[:]
</code></pre><p><strong>&#x904D;&#x5386;</strong>  </p>
<pre><code class="lang-python"><span class="hljs-keyword">for</span> x <span class="hljs-keyword">in</span> mylist:  
    print(x)
<span class="hljs-keyword">for</span> i,x <span class="hljs-keyword">in</span> enumerate(mylist):  
    print(i, x)
</code></pre>
<p><strong>&#x5176;&#x5B83;</strong><br>&#x53EF;&#x4EE5;&#x7528;&#x5207;&#x7247;&#x6765;&#x8D4B;&#x503C;&#xFF0C;&#x8BE5;&#x64CD;&#x4F5C;&#x53EF;&#x4EE5;&#x6539;&#x53D8;&#x5217;&#x8868;&#x7684;&#x5927;&#x5C0F;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;  </p>
<pre><code class="lang-python">mylist = [<span class="hljs-number">0</span>,<span class="hljs-number">1</span>,<span class="hljs-number">2</span>]
a = mylist[:]     <span class="hljs-comment">#&#x83B7;&#x5F97;&#x4E00;&#x4E2A;&#x6D45;&#x62F7;&#x8D1D;(shallow copy)&#x526F;&#x672C;</span>
a[<span class="hljs-number">1</span>:<span class="hljs-number">3</span>] = [<span class="hljs-number">10</span>,<span class="hljs-number">20</span>]  <span class="hljs-comment">#&#x66FF;&#x6362;&#x4E00;&#x4E9B;&#x5143;&#x7D20;</span>
a[<span class="hljs-number">1</span>:<span class="hljs-number">3</span>] = []       <span class="hljs-comment">#&#x79FB;&#x9664;&#x4E00;&#x4E9B;&#x5143;&#x7D20;</span>
a[:] = []         <span class="hljs-comment">#&#x6E05;&#x7A7A;&#x5217;&#x8868;</span>
</code></pre>
<h2 id="&#x5B57;&#x5178;&#xFF08;dict&#xFF09;">&#x5B57;&#x5178;&#xFF08;dict&#xFF09;</h2>
<p><strong>&#x7279;&#x70B9;</strong><br>1&#xFF09;&#x65E0;&#x5E8F;&#x3001;&#x53EF;&#x53D8;&#xFF08;&#x53EF;&#x589E;&#x5220;&#x5143;&#x7D20;&#xFF09;&#xFF1B;<br>2&#xFF09;&#x5173;&#x952E;&#x5B57;&#x5FC5;&#x987B;&#x4F7F;&#x7528;&#x4E0D;&#x53EF;&#x53D8;&#x7C7B;&#x578B;&#xFF0C;tuple&#x53EF;&#x4EE5;&#x505A;&#x5173;&#x952E;&#x5B57;&#xFF0C;&#x4F46;&#x5B83;&#x4E0D;&#x80FD;&#x76F4;&#x63A5;&#x6216;&#x95F4;&#x63A5;&#x5305;&#x542B;&#x53EF;&#x53D8;&#x7C7B;&#x578B;&#x5143;&#x7D20;&#xFF1B;<br>3&#xFF09;&#x5173;&#x952E;&#x5B57;&#x4E0D;&#x5141;&#x8BB8;&#x91CD;&#x590D;&#xFF1B;  </p>
<p><strong>&#x521B;&#x5EFA;</strong>  </p>
<pre><code>{} &#x6216;  dict()   #&#x7A7A;&#x5B57;&#x5178;
{&apos;a&apos;:1, &apos;b&apos;:2}  #&#x5355;&#x5143;&#x7D20;&#x6216;&#x591A;&#x5143;&#x7D20;
{x:x+1 for x in iterable}  #&#x5B57;&#x5178;&#x63A8;&#x5BFC;&#x5F0F;
dict(a=1, b=2) #&#x9002;&#x5408;&#x5173;&#x952E;&#x5B57;&#x90FD;&#x4E3A;&#x7B80;&#x5355;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x60C5;&#x51B5;
dict(mapping)  #mapping&#x662F;&#x5B57;&#x5178;&#xFF08;&#x4ECE;&#x4E00;&#x4E2A;&#x5B57;&#x5178;&#x521B;&#x5EFA;&#xFF0C;&#x5C06;&#x4F1A;&#x62F7;&#x8D1D;&#x4E00;&#x4E2A;&#x526F;&#x672C;&#xFF09;&#xFF0C;&#x4E0B;&#x540C;
dict(mapping, a=1, b=2)
dict(iterable)  #iterable&#x7684;&#x5143;&#x7D20;&#x4E5F;&#x5FC5;&#x987B;&#x662F;&#x4E00;&#x4E2A;iterable&#xFF0C;&#x4E14;&#x53EF;&#x904D;&#x5386;&#x51FA;2&#x4E2A;&#x5BF9;&#x8C61;:
dict(iterable, a=1, b=2)
dict.fromkeys(&apos;abc&apos;)  #&#x4ECE;&#x7ED9;&#x5B9A;&#x952E;&#x503C;&#x521B;&#x5EFA;&#xFF0C;&#x503C;&#x53EF;&#x9009;&#xFF0C;&#x9ED8;&#x8BA4;&#x4E3A;None
dict.fromkeys(&apos;abc&apos;, 100)

iterable&#x4E3E;&#x4F8B;&#xFF1A;
dict([(&apos;a&apos;,1), (&apos;b&apos;,2)])
dict(zip(&apos;ab&apos;, [1,2])) 
#zip&#x51FD;&#x6570;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;zip object(&#x662F;&#x4E00;&#x4E2A;Iterator)&#xFF0C;&#x904D;&#x5386;&#x5B83;&#x53EF;&#x5F97;&#x5230;&#x4E00;&#x7CFB;&#x5217;&#x5143;&#x7EC4;&#xFF1A;(&apos;a&apos;, 1)&#x3001;(&apos;b&apos;, 2)
</code></pre><p><strong>&#x904D;&#x5386;</strong></p>
<pre><code class="lang-python"><span class="hljs-keyword">for</span> key <span class="hljs-keyword">in</span> d.keys(): 
    print(key)
<span class="hljs-keyword">for</span> value <span class="hljs-keyword">in</span> d.values(): 
    print(value)
<span class="hljs-keyword">for</span> (key,value) <span class="hljs-keyword">in</span> d.items(): 
    print(key, value)
</code></pre>
<h2 id="dict&#x548C;list&#x7684;&#x6BD4;&#x8F83;">dict&#x548C;list&#x7684;&#x6BD4;&#x8F83;</h2>
<p>dict &#x6709;&#x4EE5;&#x4E0B;&#x51E0;&#x4E2A;&#x7279;&#x70B9;&#xFF1A;</p>
<ul>
<li>&#x67E5;&#x627E;&#x548C;&#x63D2;&#x5165;&#x7684;&#x901F;&#x5EA6;&#x6781;&#x5FEB;&#xFF0C;&#x4E0D;&#x4F1A;&#x968F;&#x7740; key &#x7684;&#x589E;&#x52A0;&#x800C;&#x589E;&#x52A0;&#xFF1B;</li>
<li>&#x9700;&#x8981;&#x5360;&#x7528;&#x5927;&#x91CF;&#x7684;&#x5185;&#x5B58;&#xFF0C;&#x5185;&#x5B58;&#x6D6A;&#x8D39;&#x591A;&#x3002;</li>
</ul>
<p>&#x800C; list &#x76F8;&#x53CD;&#xFF1A;</p>
<ul>
<li>&#x67E5;&#x627E;&#x548C;&#x63D2;&#x5165;&#x7684;&#x65F6;&#x95F4;&#x968F;&#x7740;&#x5143;&#x7D20;&#x7684;&#x589E;&#x52A0;&#x800C;&#x589E;&#x52A0;&#xFF1B;</li>
<li>&#x5360;&#x7528;&#x7A7A;&#x95F4;&#x5C0F;&#xFF0C;&#x6D6A;&#x8D39;&#x5185;&#x5B58;&#x5F88;&#x5C11;&#x3002;</li>
</ul>
<p>&#x6240;&#x4EE5;&#xFF0C; dict &#x662F;&#x7528;&#x7A7A;&#x95F4;&#x6765;&#x6362;&#x53D6;&#x65F6;&#x95F4;&#x7684;&#x4E00;&#x79CD;&#x65B9;&#x6CD5;&#x3002;</p>
<h2 id="&#x5E8F;&#x5217;&#x7684;&#x589E;&#x91CF;&#x8D4B;&#x503C;">&#x5E8F;&#x5217;&#x7684;&#x589E;&#x91CF;&#x8D4B;&#x503C;</h2>
<p>&#x589E;&#x91CF;&#x8D4B;&#x503C;&#x8FD0;&#x7B97;&#x7B26; += &#x548C; *= &#x7684;&#x8868;&#x73B0;&#x53D6;&#x51B3;&#x4E8E;&#x5B83;&#x4EEC;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x64CD;&#x4F5C;&#x5BF9;&#x8C61;&#x3002;&#x4EE5;+=&#x4E3A;&#x4F8B;&#x6765;&#x4ECB;&#x7ECD;&#xFF1A;<br>+= &#x80CC;&#x540E;&#x7684;&#x7279;&#x6B8A;&#x65B9;&#x6CD5;&#x662F; <code>__iadd__</code> &#xFF08; &#x7528;&#x4E8E;&#x201C;&#x5C31;&#x5730;&#x52A0;&#x6CD5;&#x201D;&#xFF09; &#x3002; &#x4F46;&#x662F;&#x5982;&#x679C;&#x4E00;&#x4E2A;&#x7C7B;&#x6CA1;&#x6709;&#x5B9E;&#x73B0;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#x7684;&#x8BDD;&#xFF0C; Python &#x4F1A;&#x9000;&#x4E00;&#x6B65;&#x8C03;&#x7528; <code>__add__</code> &#x3002;  &#x90A3;&#x6837;&#x7684;&#x8BDD; a += b &#x8FD9;&#x4E2A;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x6548;&#x679C;&#x5C31;&#x53D8;&#x5F97;&#x8DDF; a = a + b &#x4E00;&#x6837;&#x4E86;&#xFF1A; &#x9996;&#x5148;&#x8BA1;&#x7B97; a + b&#xFF0C; &#x5F97;&#x5230;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x5BF9;&#x8C61;&#xFF0C; &#x7136;&#x540E;&#x8D4B;&#x503C;&#x7ED9; a&#x3002;<br> &#x8003;&#x8651;&#x4E0B;&#x9762;&#x8FD9;&#x4E2A;&#x7B80;&#x5355;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#xFF1A;</p>
<pre><code class="lang-python">a += b      <span class="hljs-comment">#&#x5982;&#x679C; a &#x5B9E;&#x73B0;&#x4E86; __iadd__ &#x65B9;&#x6CD5;&#xFF0C; &#x5C31;&#x4F1A;&#x8C03;&#x7528;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#x3002;</span>
c = c + d   <span class="hljs-comment">#&#x5C06;&#x4F1A;&#x4EA7;&#x751F;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x5E8F;&#x5217;&#xFF0C;&#x6548;&#x7387;&#x4E0D;&#x9AD8;&#x3002;</span>
</code></pre>
<blockquote>
<p>&#x53EF;&#x53D8;&#x5E8F;&#x5217;&#x4E00;&#x822C;&#x90FD;&#x5B9E;&#x73B0;&#x4E86;  <code>__iadd__</code> &#x65B9;&#x6CD5;&#xFF0C; &#x56E0;&#x6B64; += &#x662F;&#x5C31;&#x5730;&#x52A0;&#x6CD5;&#x3002;</p>
</blockquote>
<h2 id="&#x5E8F;&#x5217;&#x4F7F;&#x7528;&#x91CD;&#x590D;&#x7684;&#x9677;&#x9631;">&#x5E8F;&#x5217;&#x4F7F;&#x7528;<code>*</code>&#x91CD;&#x590D;&#x7684;&#x9677;&#x9631;</h2>
<p>&#x4F7F;&#x7528;<code>*</code>&#x6765;&#x91CD;&#x590D;&#x5E8F;&#x5217;&#xFF0C;&#x5E8F;&#x5217;&#x91CC;&#x7684;&#x53EF;&#x53D8;&#x5143;&#x7D20;&#x5C06;&#x4F1A;&#x4EE5;&#x5F15;&#x7528;&#x7684;&#x65B9;&#x5F0F;&#x91CD;&#x590D;&#x3002;<br>&#x4E3E;&#x4F8B;&#xFF1A;  </p>
<pre><code class="lang-python"><span class="hljs-meta">&gt;&gt;&gt; </span>mylist = [[<span class="hljs-number">0</span>] * <span class="hljs-number">3</span>] * <span class="hljs-number">3</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>mylist
[[<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>], [<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>], [<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]]
<span class="hljs-meta">&gt;&gt;&gt; </span>mylist[<span class="hljs-number">0</span>][<span class="hljs-number">0</span>] = <span class="hljs-number">1</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>mylist
[[<span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>], [<span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>], [<span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]]
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="字符串处理.html" class="navigation navigation-prev " aria-label="Previous page: 字符串处理">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="数据结构高级内容.html" class="navigation navigation-next " aria-label="Next page: 数据结构高级内容">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"数据结构","level":"1.4","depth":1,"next":{"title":"数据结构高级内容","level":"1.5","depth":1,"path":"数据结构高级内容.md","ref":"数据结构高级内容.md","articles":[]},"previous":{"title":"字符串处理","level":"1.3","depth":1,"path":"字符串处理.md","ref":"字符串处理.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"数据结构.md","mtime":"2017-08-23T14:52:53.514Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2017-08-27T04:11:18.522Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

